package oo4;

//给宠物加上feed(String foodName)方法，增加体力。。。
//父类中feed抽象化，主人喂食，只考虑Pet....
public abstract class Pet {
	protected String name;
	private int health;
	private int love;
	private String sex;

	public Pet() {
		System.out.println("无参的构造方法");
	}

	public Pet(String name, int health, int love, String sex) {
		super();
		System.out.println("4个参数的构造方法");
		this.name = name;
		this.health = health;
		this.love = love;
		this.sex = sex;
	}

	public abstract void feed(String food);

	public abstract void eat();

	public void show() {
		System.out.println("名字叫：" + name);
		System.out.println("健康值：" + this.health);
		System.out.println("可爱程度：" + this.love);
		System.out.println("性别：" + sex);
	}

	private void increase() {
		this.health++;
		this.love++;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public int getLove() {
		return love;
	}

	public void setLove(int love) {
		if (love > 100 || love < 0)
			love = 60;
		this.love = love;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Override
	public boolean equals(Object obj) {
		// this和obj来比
		// 比较name
		Pet p = (Pet) obj;
		return this.name.equals(p.name);
	}

	@Override
	public String toString() {
		return "这个宠物的名字叫" + name + ",可爱度：" + this.love + ",健康值：" + this.health + ",性别是：" + sex;
	}
}
